﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/Admin/_AdminLayout.cshtml";
}
@using PagedList
@using PagedList.Mvc
<div style="background: #fff; text-align: right; height: 60px; width: 100%; font-size: 12px; border: 1px solid #ccc;">
    <span style="font-size: 18px; font-weight: bold; float: left; padding-top: 17px; padding-left: 15px;">
        <img src="../../Content/Images/Admin/product.png" />
        USER
    </span>
</div>
<br />
<a href="~/AdminThuongHieu/ThemThuongHieu" class="normal blue button input">Thêm mới</a>
<a href="~/admin" class="normal black button input">Thoát</a>
@Html.Raw(ViewBag.ThongBao)
<br />
<br />
<table cellspacing="0" rules="rows" class="rows" border="1" style="width: 100%; border-collapse: collapse;">
    <tr class="item_title" style="color: White; background-color: #CCCCCC; font-family: Tahoma; font-size: 12px; font-weight: bold; height: 30px;">
        <th>ID</th>
        <th>Tên thương hiệu</th>
        <th>Xuất xứ</th>
        <th></th>
        <th></th>
    </tr>
    @{PagedList<BabyToys.Models.ThuongHieu> thuonghieus = ViewBag.OnePageOfThuongHieu;}
    @foreach (var thuonghieu in thuonghieus)
    {
        <tr class="item_row" style="border-color: #F0F0F0; border-style: Solid; height: 40px;">
            <td class="item_float">
                <label>
                    @thuonghieu.IdThuongHieu
                </label>
            </td>
            <td class="item_float">
                <label>
                    @thuonghieu.TenThuongHieu
                </label>
            </td>
            <td class="item_float">
                <label>
                    @thuonghieu.QuocGia
                </label>
            </td>
            
            <td class="item_float">
                <input id="@Html.Raw("chkHienThi" + thuonghieu.IdThuongHieu)" type="checkbox" onclick="CapNhatHienThi(@thuonghieu.IdThuongHieu)" @if (thuonghieu.HienThi == true)
                                                                                                  {
                                @:checked="checked"
                            }
                                @Html.Raw(ViewBag.Xoa==true?"":"disabled=\"disabled\"")
                            />
                    <script>
                        function CapNhatHienThi(id) {
                            var ten = '#chkHienThi' + id;
                            var hienthi = $(ten).is(':checked') ? true : false;
                            //alert("a:"+x+"b:"+id);
                            var x = confirm("Bạn có chắc muốn cập nhật sản phẩm này?");
                            if (x == true) {
                                //var ten = '#IsActive' + id;
                                var id = id;
                                $.post("/AdminThuongHieu/CapNhatHienThi/", { "id": id, "hienthi": hienthi },
                                    function (data) {
                                        alert("Cập Nhật Thành Công");
                                    });
                            }
                            else {
                                window.location.reload();
                            }
                        }
                            </script>
            </td>
            <td class="item_float">
                <div class="hidden-phone visible-desktop action-buttons">
                    <a href="~/AdminThuongHieu/SuaThuongHieu/@thuonghieu.IdThuongHieu" class="small blue button btnSua">Sửa</a>
                </div>
            </td>
        </tr>
    }
</table>

@Html.PagedListPager((IPagedList)ViewBag.OnePageOfThuongHieu, page => Url.Action("Index", new { page }), PagedListRenderOptions.OnlyShowFivePagesAtATime)